package com.wkhyapp.lm.adapter;

import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wkhyapp.lm.R;
import com.wkhyapp.lm.adapter.base.HolderEntity;
import com.wkhyapp.lm.adapter.base.MirAdapter;
import com.wkhyapp.lm.http.vo.CCategory;
import com.wkhyapp.lm.http.vo.Goods;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fang on 2022/1/17.
 */

public class CCategoryAdapter extends MirAdapter<CCategory>{


    public CCategoryAdapter.callBack mCallBack;
    int items  = 0;
    List<Integer> ids  = new ArrayList<>();
    public CCategoryAdapter(Context context, List<CCategory> mDatas, int itemLayoutId) {
        super(context, mDatas, itemLayoutId);
    }

    @Override
    public void convert(final HolderEntity helper, final CCategory item) {
        ids.add(helper.getPosition());
        RelativeLayout relativeLayout = helper.getView(R.id.text_rl);
       final   TextView textView =  helper.getView(R.id.item_tv);
        textView.setText(item.getName());
        helper.getView(R.id.item_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.jump(item,helper.getPosition());
                for(int i=0;i<ids.size();i++ ){
                    if(items == ids.get(i)){
                        textView.setTextColor(R.color.blue);
                    }else{
                        textView.setTextColor(R.color.yancy_deeporangea400);
                    }

                }
            }
        });
    }

    public void  setCallBack(CCategoryAdapter.callBack callBack){
        this.mCallBack = callBack;
    }


    public void setItem(int items){
        this.items = items;
    }

    public interface  callBack{
        void jump(CCategory item,int index);

    }

}
